package com.aifund.common.dao;

import com.aifund.common.entity.ExchangeManTactics;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface ExchangeManTacticsDao extends JpaRepository<ExchangeManTactics,Long> {


    ExchangeManTactics getById(Long id);

    /**
     * 根据交易所ID和策略状态获取交易员ID列表
     * @param exchangeId
     * @param status
     * @return
     */
    @Query(nativeQuery = true,value = "select user_id from exchange_man_tactics where is_del = 0 and exchange_id = ?1 and status = ?2")
    List<Long> getAllManByExchangeIdAndStatus(Long exchangeId,Integer status);

    List<ExchangeManTactics> findAllByExchangeIdAndStatus(Long exchangeId,Integer status);

    /**
     * 根据交易员ID和状态获取交易所列表
     * @param userId
     * @param status
     * @return
     */
    @Query(nativeQuery = true,value = "select exchange_id from exchange_man_tactics where is_del = 0 and user_id = ?1 and status = ?2")
    List<Long> getExchangeIdByUserIdAndStatus(Long userId, Integer status);

}
